package com.insta.formation.calendar.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.insta.formation.calendar.dao.IPersonDao;
import com.insta.formation.calendar.model.Person;

public class PersonDaoImpl extends GenericDaoImpl<Person, Integer> implements IPersonDao 
{

	public PersonDaoImpl(Class<Person> type) {
		super(type);
	}

	/**
	 * 	@see IPersonDao.findByEmail
	 */
	public Person findByEmail(String email) {
		Criteria crit =
				 getSession().createCriteria(Person.class).add(Restrictions.eq("email",
				 email));
		crit.setMaxResults(1);
		return (crit.list().isEmpty() ? null : (Person) crit.list().get(0));
	}
	
	

}
